package com.bml.architect.netty.serialiable;

import com.bml.architect.entity.MsgProto;
import com.bml.architect.entity.User;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;

public class SerialServerHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("接受到客户端发送过来的消息="+msg);
        MsgProto msgProto = (MsgProto) msg;
        System.out.println("接受的数据长度："+msgProto.getLength());
        System.out.println("接受的数据内容："+new String(msgProto.getContent(),"UTF-8"));
    }

//    @Override
//    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
//        System.out.println("客户端数据读取完毕");
//        User user = new User();
//        user.setAddress("四川成都市温江区");
//        user.setName("李四");
//        user.setId(2);
//        ctx.writeAndFlush(user);
//    }
}
